<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>加减计数器</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            font-family: Arial, sans-serif;
        }
        .counter-container {
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 24px;
        }
        .counter-container button {
            padding: 10px 20px;
            font-size: 20px;
            cursor: pointer;
        }
        .counter-value {
            font-size: 24px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="counter-container">
        <button id="decrement-btn">-</button>
        <div class="counter-value" id="counter-value">0</div>
        <button id="increment-btn">+</button>
    </div>

    <script>
        const counterValueElement = document.getElementById('counter-value');
        let counterValue = 0;

        document.getElementById('increment-btn').addEventListener('click', () => {
            counterValue++;
            counterValueElement.textContent = counterValue;
        });

        document.getElementById('decrement-btn').addEventListener('click', () => {
            counterValue--;
            counterValueElement.textContent = counterValue;
        });
    </script>
</body>
</html>